<<<<<<< HEAD
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>判断一个字符串中出现次数最多的字符，并统计次数</title>
</head>
<body>

</body>
</html><script type="text/javascript">
    function createNonSortedArray(size){ //{6}
        var array = new ArrayList();
        for (var i = size; i> 0; i--){
            array.insert(i);
        }
        return array;
    }

    function ArrayList(){
        var array = []; //{1}
        this.insert = function(item){ //{2}
            array.push(item);
        };
        this.toString= function(){ //{3}
            return array.join();
        };
        this.insertionSort = function(){
            let len = array.length,j,temp;
            //j 就是当前排序数组里面的最大值。
            for (let i = 1; i < len; i++) {
                temp = array[i];
                j = i;
                while (j > 0 && array[j -1] > temp) {
                    array[j] = array[j -1];
                    j -- ;
                }
                array[j] = temp
            }
        };
    }

    var swap = function(array, index1, index2){
        var aux = array[index1];
        array[index1] = array[index2];
        array[index2] = aux;
    };

    let array = createNonSortedArray(6); //{7}
    console.log(array.toString()); //{8}
    array.insertionSort(); //{9}
    console.log(array.toString());

</script>
=======
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>判断一个字符串中出现次数最多的字符，并统计次数</title>
</head>
<body>
<script type="text/javascript">
    var s = 'aaabbbcccaaabbbaaa';
    var obj = {}
    var maxLetter = ''
    var time = 0;
    var tempArr = s.split('')
    var len = tempArr.length;
    for(var i  = 0; i <len;i++){
        if(obj[tempArr[i]]){
            obj[tempArr[i]]++;
            maxLetter = tempArr[i];
            time = obj[tempArr[i]];
        }else {
            obj[tempArr[i]] = 1
        }
    }
    console.log(maxLetter,time)
</script>
<script type="text/javascript">
    var s = 'aaabbbcccaaabbbaaabbbbbbbbbb';
    var a = s.split('');
    a.sort();
    s = a.join('');
    var pattern = /(\w)\1*/g;
    var ans = s.match(pattern);
    ans.sort(function(a, b) {
        return a.length < b.length;
    });
    console.log(ans)
</script>
</body>
</html>
>>>>>>> 6cb7571c10ac058e4a6def413f3013f51b05f372
